MonitorTableView = function(table){
	this.table = table;
	this.panelColor = "#000000";
	this.divId="table_div";
	this.isPadding = false;
};

MonitorTableView.prototype = {
	
	/* 设置表格标示 */	
	setTableId:function(tableId){
		this.tableId = tableId;
	},
	
	/* 设置标题颜色 */
	setPanelColor:function(panelColor){
		this.panelColor = panelColor;
	},
	
	/* 设置填充表格部分的DIV标示 */
	setDivId:function(divId){
		this.divId = divId;
	},
	
	/* 设置是否清除表内距 */
	setIsPadding:function(isPadding){
		this.isPadding = isPadding;
	},
	
	/* 设置按钮 */
	setButtons:function(buttons){
		this.buttons = buttons;
	},
	
	/* 数据装载 */
	load:function(){
		this.remove();
		var thead = this.getHead();
		var tbody = this.getBody();
		$('#'+this.tableId).append(thead);
		$('#'+this.tableId).append(tbody);
	},
	
	/* 装载DIV */
	loadDiv:function(){
		var tdiv = this.getDiv();
		$("#"+this.divId).append(tdiv);
	},
	
	/* 数据刷新 */
	refresh:function(){
		this.remove();
		this.load();
	},
	
	/* 移除页面数据 */
	remove:function(){
		$('#'+this.tableId+" thead").remove();
		$('#'+this.tableId+" tbody").remove();
	},
	
	/* 获取表格头 */
	getHead:function(){
		var thead = "";
		thead += "<thead><tr class='warning'>";
		for(var i=0;i<this.table.getColumnCount();i++){
			if(this.isPadding == true){
				thead += "<th class='padding-clear'>";
			}else{
				thead += "<th>";
			}		
			thead += this.table.getColumnValue(i);
			thead += "</th>";
		}
		thead += "</tr></thead>";
		return thead;
	},
	
	/* 获取表格体 */
	getBody:function(){
		var tbody = "";
		
		tbody += "<tbody>";		
		for(var i=0;i<this.table.getRowCount();i++){
			tbody += "<tr>";
			for(var j=0;j<this.table.getColumnCount();j++){
				if(this.isPadding == true){
					tbody += "<td class='padding-clear'>";
				}else{
					tbody += "<td>";
				}			
				tbody += this.table.getFieldValue(i,j);
				tbody += "</td>";
			}
			tbody += "</tr>";
		}
		
		tbody += "</tbody>";		
		return tbody;
	},
	
	/* 获取表格填充DIV */
	getDiv:function(){
		
		var tdiv = "";
		
		tdiv += "<div class='xs'>";
		
		tdiv += "<div class='panel panel-warning panel-clear' style='border-color: "+this.panelColor+";' data-widget='{&quot;draggable&quot;: &quot;false&quot;}' data-widget-static=''>";
		
		//表格头
		tdiv += "<div class='panel-heading' style='background-color: "+this.panelColor+";'>";
		
		//按钮处理
		if(this.buttons != undefined){
			var mtbutton = new MonitorButton(this.buttons);
			tdiv += mtbutton.getAllDiv();
		};
		
		tdiv += "<h2>"+this.table.tlable+"</h2>";
		tdiv += "</div>";
		//表格体
		tdiv += "<div class='panel-body no-padding table-responsive' style='display: block;'>";
		tdiv += "<table class='table table-striped' id='"+this.table.tid+"'></table>"
		tdiv += "</div>";
		
		tdiv += "</div>";
		
		tdiv += "</div>";
		
		return tdiv;
	}
	
};